package net.caixiaomi.info.Lottery.utils;

import net.caixiaomi.info.Lottery.model.BallItem;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Random;

/**
 * Created by suntian on 2018/8/9.
 */

public class RandomUtils {

    /**
     * type:0大乐透
     * count:注数
     * @param count
     * @param type
     * @return
     */
    public static List<List<BallItem>> getRandomList(int count,int type){
        List<List<BallItem>> list=new ArrayList<>();

        return list;
    }

    private static Random randomCode = new Random(System.currentTimeMillis()); // 产生随机码
    /**
     * 产生min到max随机数
     *
     * @param min
     *            随机数最小值
     * @param max
     *            随机数最大值
     * @return
     */
//    public static int getRandom(int min, int max) {
//        return randomCode.nextInt(max - min) + min;
//    }

    public static int[] getRandomNum(int max,int min,int count){
        int[] counts=new int[count];
        HashMap<Integer,Integer> hashMap=new HashMap<>();
        for(int i=0;i<counts.length;i++){
            int num=randomCode.nextInt(max - min) + min;
            if(i!=0){
                while (hashMap.get(num)!=null){
                    num=randomCode.nextInt(max - min) + min;
                }
            }
            counts[i]=num;
            hashMap.put(num,num);
            // 排序
        }
        Arrays.sort(counts);
        return counts;
//        String[] cc=new String[counts.length];
//        for(int i=0;i<counts.length;i++){
//            int num=counts[i];
//            String target=num<10?"0"+num:""+num;
//            cc[i]=target;
//        }
//        return cc;
    }
}
